<template>
    <div class="row">
        <el-checkbox v-model="comp.enabled">{{ comp.__classname__ }}</el-checkbox>
        <el-button round size="small" :icon="Document" @click="gm.toConsole(comp)"></el-button>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>Content</el-text>
        <el-input size="small" type="textarea" v-model="comp.string" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>HorizontalAlign</el-text>
        <el-radio-group v-model="comp.horizontalAlign" size="small" class="width-full">
            <el-radio-button v-for="item in horizontalAlign.__enums__" :label="item.name" :value="item.value" />
        </el-radio-group>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>VerticalAlign</el-text>
        <el-radio-group v-model="comp.verticalAlign" size="small" class="width-full">
            <el-radio-button v-for="item in verticalAlign.__enums__" :label="item.name" :value="item.value" />
        </el-radio-group>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>FontSize</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.fontSize" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>Color</el-text>
        <el-color-picker size="small" color-format="hex" show-alpha v-model="Model.fontColor" />
        <el-input size="small" v-model="Model.fontColor" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>UseSystemFont</el-text>
        <el-checkbox v-model="comp.useSystemFont" />
        <el-input v-if="comp.useSystemFont" size="small" disabled :value="comp.fontFamily" />
        <el-input v-if="!comp.useSystemFont" size="small" disabled :value="gm.targetName(comp.font)" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>CacheMode</el-text>
        <el-select v-model="comp.cacheMode" size="small">
            <el-option v-for="item in cacheMode.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>MaxWidth</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.maxWidth" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>LineHeight</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.lineHeight" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>ImageAtlas</el-text>
        <el-input size="small" disabled :value="gm.targetName(comp.imageAtlas)" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>HandleTouchEvent</el-text>
        <el-checkbox v-model="comp.handleTouchEvent" />
    </div>
</template>

<script lang="ts" setup>
import { Document } from '@element-plus/icons-vue'
import gm from './gm';

const props = defineProps<{
    comp: CCComponent,
    update: Number,
}>()
const horizontalAlign = cc.Label.HorizontalAlign
const verticalAlign = cc.Label.VerticalAlign
const overflow = cc.Label.Overflow
const cacheMode = cc.Label.CacheMode

class Model{
    static get comp() {
        return props.comp
    }

    static get fontColor() {
        return gm.toHexColor(this.comp.fontColor)
    }

    static set fontColor(value: string) {
        this.comp.fontColor = gm.toCCColor(value)
    }
}
</script>